package org.example.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {

    private int code;
    private Object data;
    private String message;

    public static JsonResult buildSuccess() {
        return new JsonResult(0, null, null);
    }
    public static JsonResult buildSuccess(String message) {
        return new JsonResult(0, null, message);
    }
    public static JsonResult buildSuccess(Object data) {
        return new JsonResult(0, data, null);
    }
    public static JsonResult buildSuccess(Object data, String message) {
        return new JsonResult(0, data, message);
    }
    public static JsonResult buildSuccess(int code, Object data, String message) {
        return new JsonResult(code, data, message);
    }
    public static JsonResult buildError() {
        return new JsonResult(-1, null, null);
    }
    public static JsonResult buildError(String message) {
        return new JsonResult(-1, null, message);
    }
    public static JsonResult buildError(Object data, String message) {
        return new JsonResult(-1, data, message);
    }
    public static JsonResult buildError(int code, Object data, String message) {
        return new JsonResult(code, data, message);
    }
    public static JsonResult buildError(int code, Object data) {
        return new JsonResult(code, data, null);
    }
}
